<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="git项目管理总结, lujiangyao github">
    <meta name="description" content="if you risk nothing,then you risk anthing">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>git项目管理总结 | lujiangyao</title>
    <link rel="icon" type="image/png" href="/blog/favicon.png">

    <link rel="stylesheet" type="text/css" href="/blog/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/blog/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/blog/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/blog/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/blog/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/blog/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/blog/css/my.css">

    <script src="/blog/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 5.4.0"><link rel="stylesheet" href="/blog/css/prism-tomorrow.css" type="text/css"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/blog/" class="waves-effect waves-light">
                    
                    <img src="/blog/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">lujiangyao</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/blog/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/blog/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/blog/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/blog/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/blog/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/blog/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/blog/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">lujiangyao</div>
        <div class="logo-desc">
            
            if you risk nothing,then you risk anthing
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/blog/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/blog/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/blog/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/blog/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/blog/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/blog/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>
<!-- 
<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a> -->
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/blog/medias/featureimages/8.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">git项目管理总结</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/blog/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    .toc-fixed .toc-link::before{
        position: fixed!important;/*当toc的位置改为fixed时，.toc-link::before也要改为fixed*/
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/blog/tags/Git%E9%A1%B9%E7%9B%AE%E5%BC%80%E5%8F%91%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86/">
                                <span class="chip bg-color">Git项目开发版本管理</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/blog/categories/Git/" class="post-category">
                                Git
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2021-03-28
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2021-03-28
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    3.3k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    12 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1><span id="git项目管理总结">git项目管理总结</span></h1><h3><span id="开发中的运用">开发中的运用</span></h3><p>一般的在多人开发的过程中，一开机我们开始需要先git pull拉取一下远程的代码，再进行编写</p>
<p>当我们一顿操作写完代码之后</p>
<h4><span id="基本操作">基本操作</span></h4><pre><code>//先查看一下我们的修改的代码的文件，是否是正确
git status
//下面将想要提交的文件add一遍，下面的 ‘.‘ 表示修改的所有文件，当然你也可以一个一个的add，看一下上一步的路径将 ’.‘ 替换为对应的路径就好了
git add .
//再查看一下状态，是否是预期add的文件，一般的我都会去vscode再次确认自己所修改的东西是否正确，会不会有什么测试代码没去除的
git status
//下边将代码保存到本地，下面的注释可能大家的规范也不太一致，我是用fix代表的修复bug，只举个例子，注释清晰，才好复查每个提交的记录
git commit -m &quot;fix：修复什么什么&quot;
//拉取一下远程代码，有冲突则解决冲突
git pull
（如果有冲突解决冲突保存文件之后要再add一次和commit一次）：git add .   ----&gt;   git commit -m &quot;chore:解决冲突&quot;
//上传到远程仓库
git push</code></pre><h4><span id="合并分支">合并分支</span></h4><pre><code>//先查看一下远程分支
git branch -r
//先切换分支到想要合并的目标分支(在上一步复制一下目标分支名)
git checkout 分支名
//拉去一下最新的代码
git pull
//如果是将目标分支合并到自己的开发分支,这时就需要切回自己的开发分支了
git checkout 分支名
//合并目标分支
git merge 分支名
//然后此时会弹出合并注释输入英文 :wq 然后回车
//如果有冲突,则解决冲突跟上面的基本操作一样解决冲突然后保存再add一次然后commit
//最后一步如果需要提交到远程的话
git push</code></pre><h4><span id="如果再修改着一个bug还没修完但是你需要去处理另外一个紧急的bug此时你改的东西还不想commit">如果再修改着一个bug还没修完,但是你需要去处理另外一个紧急的bug,此时你改的东西还不想commit</span></h4><p>解决方法:</p>
<pre><code>//将代码暂存再栈里面
git stash save &quot;注释&quot;
//此时你会发现修改的代码的文件全没了,不用担心,只是存起来了,执行下面命令行查看是否真的存在栈里面
git stash list
//此时你就可以切换分支去修改你的紧急的bug了
//然后修改完后你想继续修改原来的bug了,先查看栈信息,查看一下自己的是存在哪个索引里(因为可能你同事也存了)
git stash list 
//下面分两种情况:
//1.(如果只有你自己一个存了) 直接  git stash pop     //恢复到工作区
git stash pop
//2.(如果出现多条,还有其他同事存了),那么就要看看你的是存再哪个索引里,下面我以再索引 0 为例子 //恢复到工作区
git stash pop stash@&#123;0&#125;
//上面恢复到工作区后,就就又可以看到你之前修改的代码了
//下面,如果你不想要了,想再重新写也行,但是你要清理一下你存的那个信息,下面选一个
git stash drop [stash_id] 删除一个存储的进度，如果不指定stash_id，则默认删除最新的存储进度
git stash clear 删除所有栈</code></pre><h4><span id="版本回滚和回退">版本回滚和回退</span></h4><p>回退： reset      //回退到某次提交，然后某次提交之后的都会没掉</p>
<p>回滚： revert   //撤销中间的某一次的提交，某次提交之后的提交还会存在</p>
<p>版本回退在开发中都是一件比较慎重的事，除非还没提交到远程的，不到万不得已的情况下我们一般不怎么想回退</p>
<p>碰到有以下几种情况：</p>
<p>在多人开发中，我们一般都会分需求开发，然后再合并到同一个分支上</p>
<h5><span id="1如果只是在自己的开发分支可以使用reset回退或者revert回滚版本">1.如果只是在自己的开发分支，可以使用reset回退或者revert回滚版本</span></h5><pre><code>revert：
//我们先查看当前分支提交日志
git log
//通过提交日志，我们可以找到对应的提交记录的commit_id,然后执行revert撤销掉那个commit_id的提交
git revert commit_id
//如果你想取消这次 revert 可以执行 取消回滚:   git revert --abort
//最后一步 
git push

reset:
//同上，查看当前分支提交日志
git log
//然后找到对应的commit_id，回退到对应的commit_id的提交
git reset --hard commit_id
//最后一步 
git push</code></pre><h5><span id="2如果你回退-回滚的是合并的记录那么这里就需要注意了">2.如果你回退 / 回滚的是合并的记录，那么这里就需要注意了</span></h5><pre><code>revert：（慎重使用revert撤回合并记录）
//我们先查看当前分支提交日志
git log
//通过提交日志，我们可以找到对应的提交记录的commit_id,然后执行revert撤销掉那个commit_id的提交
//！！！注意：那么如果你后面在次合并，但这次修改涉及到上次回退涉及到的代码时，再次合并那部分代码即使再合并过来也不会复现，如果需要拿回之前部分的代码，并进行合并那么则需要revert上一次的回滚了
git revert commit_id
//如果你想取消这次 revert 可以执行 取消回滚:   git revert --abort
//最后一步 
git push



reset:
//同上，查看当前分支提交日志
git log
//然后找到对应的commit_id，回退到对应的commit_id的提交
git reset --hard commit_id
//最后一步 
git push
//如果你回退的那次提交后面还有同事合并过，那么你就需要通知一下你的同事，叫他们再合并过来一次</code></pre><h4><span id="cherry-pick将指定某次或者某几次提交提交到某个分支修复某些bug如果你有一些什么其他私有化的项目分支也需要修复">cherry-pick将指定某次或者某几次提交提交到某个分支——修复某些bug，如果你有一些什么其他私有化的项目分支也需要修复</span></h4><p>可以使用cherry-pick</p>
<pre><code>//首先还是地查看提交日志
git log --all   //查看所有分支的历史

对于多分支的代码库，将特定的几个提交移到另一个分支是常见需求
git cherry-pick &lt;commitHash&gt; 将指定的提交commitHash，应用于当前分支
git cherry-pick feature 表示将feature分支的最近一次提交，转移到当前分支
git cherry-pick &lt;HashA&gt; &lt;HashB&gt; 转移多个commit到当前分支
git cherry-pick A..B 转移从 A 到 B 的所有提交. 注意不包含提交 A 如果要包含提交 A使用git cherry-pick A^..B

（想回到 cherry-pick 之前，那么可以使用 git cherry-pick --abort ）</code></pre><h4><span id="rabase变基">rabase变基</span></h4><p>（变基在很多分支开发的情况下，可以用于多分支开发提交变成一条直线的提交，方便查看）</p>
<pre><code>git rebase 分支名</code></pre><p>下面以master为例子：</p>
<p>git rebase master</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/clipboard200.png" alt="rabase"></p>
<h4><span id="git从某个提交检出新分支">git从某个提交检出新分支</span></h4><p>从某一个commit开始创建本地分支 </p>
<p>1、git log 查看提交</p>
<p>2、通过checkout 跟上commitId 即可创建制定commit之前的本地分支 </p>
<p>git checkout commitId -b 本地新branchName </p>
<p>上传到远程服务器 </p>
<p>依然通过push 跟上你希望的远程新分支名字即可 </p>
<p>git push origin HEAD:远程新branchName </p>
<h4><span id="解决git-pullpush每次都需要输入密码问题">解决git pull/push每次都需要输入密码问题</span></h4><ol>
<li><p>git bash进入你的项目目录，输入：</p>
</li>
<li><p>git config –global credential.helper store</p>
</li>
</ol>
<p>然后你会在你本地生成一个文本，上边记录你的账号和密码。当然这些你可以不用关心。</p>
<p>然后你使用上述的命令配置好之后，再操作一次git pull，然后它会提示你输入账号密码，这一次之后就不需要再次输入密码了</p>
<h4><span id="切换远程仓库">切换远程仓库</span></h4><h6><span id="如果a是已有仓库b是新建立的空仓库">如果A是已有仓库，B是新建立的空仓库。</span></h6><p>1、在本地拉一下（git clone）A仓库的代码，或者是git pull 下最新的代码。</p>
<p>2、git remote? ?# 查看本地连接的有哪些 远程仓库，默认是 origin</p>
<p>3、git remote add origin2(这个名字随便起) master? ?#?这里是在本地添加一个新的远程连接</p>
<p>4、git remote set-url origin2 B仓库的地址? ?#?这里是新加个远程连接 设置上url地址</p>
<p>5、在A的本地仓库? git push origin2 dev:master? ?#?origin2 是你想push上哪个远程库，dev 是你想push哪个分支，master 是push到远程的哪个分支。? ? 这个命令执行以后要输密码，记得是新仓库的密码。</p>
<h6><span id="远程仓库已经存在master分支">远程仓库已经存在master分支</span></h6><p>远程master的代码是无用的并且可以使用强推</p>
<p>//添加仓库</p>
<p>git remote add origin &lt;仓库地址&gt;</p>
<p>//强制push本地master分支到远端的master分支</p>
<p>git push origin master:master -f</p>
<h6><span id="远程仓库未创建分支">远程仓库未创建分支</span></h6><p>//添加仓库</p>
<p>git remote add origin &lt;仓库地址&gt;</p>
<p>//push本地master分支新建远端master分支</p>
<p>git push origin master:master</p>
<p>—另一个方法：使用镜像（还没使用过）</p>
<p>git push –mirror http://…(目标仓库地址)</p>
<h3><span id="查看git账号名及邮箱">查看git账号名及邮箱</span></h3><pre><code>git config user.name
git config user.email</code></pre><h3><span id="修改全局配置git-账号及邮箱">修改全局配置git 账号及邮箱</span></h3><pre><code>git config --global user.name &quot;账号名&quot;
git config --global user.email &quot;邮箱名&quot;</code></pre><h3><span id="配置局部git账号">配置局部git账号</span></h3><pre><code>git config user.name &quot;账号名&quot;
git config user.email &quot;邮箱名&quot;</code></pre><h4><span id="如果开始输入密码错误">如果开始输入密码错误</span></h4><p>remote: HTTP Basic: Access denied</p>
<p>fatal: Authentication failed for ‘http://<strong>****</strong></p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/clipboard22.png" alt="错误信息"></p>
<p>解决方案：</p>
<p>git config –system –unset credential.helper</p>
<p>之后再进行git操作时，弹出用户名密码窗口，输入即可</p>
<h3><span id="查看分支历史提交日志">查看分支历史（提交日志）</span></h3><pre><code>查看所有分支的历史 git log --all   图形化查看 git log --all --graph

查看当前分支的历史 git log

​    查看当前分支历史-简洁 git log --oneline

​    查看所有分支历史-简洁 git log --oneline --all

​    查看所有分支历史的近几个历史（此处4个） git log --oneline --all -n4

查看某个文件的历史  git log --all --full-history -- package-lock.json    //例如package-lock.json文件</code></pre><h3><span id="查看分支">查看分支</span></h3><pre><code>查看所有本地分支 git branch
查看远程所有分支 git branch -r
查看所有分支 git branch --all </code></pre><h3><span id="创建本地分支">创建本地分支</span></h3><pre><code>git branch 分支名</code></pre><h4><span id="创建分支并切换到该分支">创建分支并切换到该分支</span></h4><pre><code>git checkout -b 分支名</code></pre><h4><span id="在创建新的分支进行提交代码">在创建新的分支进行提交代码</span></h4><p>我们新建分支的时候，不能直接git push上去，只能通过下面这样</p>
<pre><code>git push --set-upstream origin  分支名</code></pre><h3><span id="删除分支">删除分支</span></h3><p>git push origin :dev  # 删除远程dev分支，危险命令哦</p>
<p># 下面两条是删除本地分支</p>
<p>git checkout master  # 切换到master分支</p>
<p>git branch -d dev  # 删除本地dev分支</p>
<h3><span id="add添加到git管理暂存区">add添加到git管理暂存区</span></h3><pre><code>git add 文件名
git add .   //暂存所有修改的文件到暂存区</code></pre><h3><span id="status查看git管理文件状态">status查看git管理文件状态</span></h3><pre><code>git status</code></pre><h3><span id="fetch更新远程分支列表">fetch更新远程分支列表</span></h3><p>一般我用的git fetch 比较多</p>
<pre><code>git fetch
git remote update origin --prune
git remote update origin -p</code></pre><h3><span id="pull拉取远程代码">pull拉取远程代码</span></h3><pre><code>git pull</code></pre><h4><span id="git-pull-和-git-fetch的区别">git pull 和 git fetch的区别</span></h4><p>git pull表示拉取更新本地的远程的分支，并拉取到最新的代码到本地，而git fetch只是拉取远程的分支跟新本地远程的分支</p>
<h3><span id="commit暂存更改">commit暂存更改</span></h3><pre><code>git commit -m &quot;注释&quot;</code></pre><p>清理暂存区的更改 </p>
<pre><code>git reset --hard</code></pre><h4><span id="修改最后一次注释">修改最后一次注释</span></h4><p>git commit –amend</p>
<p>出现有注释的界面（你的注释应该显示在第一行）， 输入i进入修改模式，修改好注释后，按Esc键 退出编辑模式，输入:wq保存并退出。</p>
<h3><span id="diff对比两个commit之间的差异">diff对比两个commit之间的差异</span></h3><p>git diff <commit_id_1> <commit_id_2></commit_id_2></commit_id_1></p>
<h3><span id="push提交本地分支到远程">push提交本地分支到远程</span></h3><pre><code>git push

git push origin 本地分支名:远程分支名（最好远程分支与本地分支同名）</code></pre><h3><span id="revert回滚">revert回滚</span></h3><pre><code>git revert commit_id 可以撤销某个commit提交，撤销会产生一个新的提交

//取消回滚
git revert --abort</code></pre><h3><span id="reset回退">reset回退</span></h3><pre><code>git reset --hard commitId</code></pre><h3><span id="stash暂存入队列栈">stash暂存入队列栈</span></h3><pre><code>git stash(场景：不想提交当前本地修改，但需要切分支修bug)
1.git stash 保存当前分支内容 入信息栈
2.git stash save &quot;注释&quot;  //添加注释
2.git stash list  //显示保存进度的列表
3.git stash pop //恢复最新的进度到工作区
4.git stash pop stash@&#123;1&#125; //恢复指定进度到工作区。stash_id是通过git stash list命令得到的
5.git stash apply //除了不删除恢复的进度之外，其余的git stash pop命令一样
6.git stash drop [stash_id] 删除一个存储的进度，如果不指定stash_id，则默认删除最新的存储进度
7.git stash clear 删除所有栈</code></pre><h3><span id="cherry-pick">cherry-pick</span></h3><pre><code>cherry-pick（场景：指定某几次提交到某个分支）
对于多分支的代码库，将特定的几个提交移到另一个分支是常见需求
git cherry-pick &lt;commitHash&gt; 将指定的提交commitHash，应用于当前分支
git cherry-pick feature 表示将feature分支的最近一次提交，转移到当前分支
git cherry-pick &lt;HashA&gt; &lt;HashB&gt; 转移多个commit
git cherry-pick A..B 转移从 A 到 B 的所有提交. 注意不包含提交 A 如果要包含提交 A使用git cherry-pick A^..B

（想回到 cherry-pick 之前，那么可以使用 git cherry-pick --abort ）</code></pre><h3><span id="rabase变基">rabase变基</span></h3><p>（变基在很多分支开发的情况下，可以用于多分支开发提交变成一条直线的提交，方便查看）    </p>
<p>git rebase master</p>
<p><img src="https://gitee.com/mo_zi_hao/picsBed/raw/master/image/clipboard200.png" alt="rabase"></p>

            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://lu-jiangyao.gitee.io/blog" rel="external nofollow noreferrer">lujiangyao</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://lu-jiangyao.gitee.io/blog/blog/2021/03/28/git%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E5%BC%80%E5%8F%91%E6%80%BB%E7%BB%93/">https://lu-jiangyao.gitee.io/blog/blog/2021/03/28/git%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E5%BC%80%E5%8F%91%E6%80%BB%E7%BB%93/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="https://lu-jiangyao.gitee.io/blog" target="_blank">lujiangyao</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/blog/tags/Git%E9%A1%B9%E7%9B%AE%E5%BC%80%E5%8F%91%E7%89%88%E6%9C%AC%E7%AE%A1%E7%90%86/">
                                    <span class="chip bg-color">Git项目开发版本管理</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/blog/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/blog/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/blog/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/blog/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/blog/2021/03/28/hello-world/">
                    <div class="card-image">
                        
                        
                        <img src="/blog/medias/featureimages/7.jpg" class="responsive-img" alt="Hello World">
                        
                        <span class="card-title">Hello World</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hex
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2021-03-28
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            lujiangyao
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/blog/2020/04/14/http/">
                    <div class="card-image">
                        
                        
                        <img src="/blog/medias/featureimages/6.jpg" class="responsive-img" alt="http">
                        
                        <span class="card-title">http</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            基本概念：HTTP，全称为 HyperText Transfer Protocol，即为超文本传输协议。是互联网应用最为广泛的一种网络协议所有的 www 文件都必须遵守这个标准。
http特性：HTTP 是无连接无状态的HTTP 一般构建于
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-04-14
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/blog/categories/http/" class="post-category">
                                    http
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/blog/tags/http/">
                        <span class="chip bg-color">http</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/blog/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/blog/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/blog/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/blog/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/blog/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/blog/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="song"
                   id="149297"
                   fixed='true'
                   autoplay='true'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/blog/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            <span id="sitetime"></span>
            Copyright&nbsp;&copy;
            <span id="year">2020</span>
            <a href="https://lu-jiangyao.gitee.io/blog" target="_blank">lujiangyao</a>
            |&nbsp;Powered by&nbsp;
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">24.9k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">


    <a href="mailto:1109738197@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1109738197" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1109738197" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/blog/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>
<script language = javascript >
    function siteTime() {
        window.setTimeout("siteTime()", 1000);
        var seconds = 1000;
        var minutes = seconds * 60;
        var hours = minutes * 60;
        var days = hours * 24;
        var years = days * 365;
        var today = new Date();
        var todayYear = today.getFullYear();
        var todayMonth = today.getMonth() + 1;
        var todayDate = today.getDate();
        var todayHour = today.getHours();
        var todayMinute = today.getMinutes();
        var todaySecond = today.getSeconds();
        var t1 = Date.UTC(2020, 04, 14, 00, 00, 00); //北京时间2020-4-14 00:00:00 
        var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond); 
        var diff = t2 - t1; var diffYears = Math.floor(diff / years); 
        var diffDays = Math.floor((diff / days) - diffYears * 365); 
        var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours); 
        var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) / minutes); 
        var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours - diffMinutes * minutes) / seconds); document.getElementById("sitetime").innerHTML = "本站已运行 " +diffYears+" 年 "+diffDays + " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒"; 
    } 
	siteTime(); 
</script>

    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/blog/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/blog/search.xml", 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/blog/libs/materialize/materialize.min.js"></script>
    <script src="/blog/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/blog/libs/aos/aos.js"></script>
    <script src="/blog/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/blog/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/blog/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/blog/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/blog/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    

    
    <script src="/blog/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
